﻿@model LetLord.Models.Landlord
@*<script src="~/Scripts/jquery-1.9.1.min.js"></script>*@
<div class="row-fluid">
    @if (Model.ResidentialProperties.Count == 0)
    {
        <h3>You haven't created any properties yet! <a href="#" id="show-create-property-modal" role="button" data-toggle="modal">Get started </a>now.</h3>
    }
    else
    {
        foreach (var property in Model.ResidentialProperties)
        {
        <div class="quick-search-result property-container">
            <div class="row-fluid">
                @if (property.PropertyPhotos.Count == 0)
                {
                    <img class="img-rounded span3" src="~/Images/noImage.jpg" />
                }
                else
                {
                    <img class="img-rounded span3" src="@Url.Action("GetPhotos", "Landlords", new { id = property.PropertyPhotos.First().ImageId })" alt="" />
                }
                <div class="row span9 address">
                    @property.Address.Line1, @property.Address.TownCity, @property.Address.County
                </div>

                <div class="row span9" style="margin-top: 10px;">
                    <div class="btn-group">
                        <button class="btn btn-primary view" data-id="@property.ResidentialPropertyId">View</button>
                        <button class="btn btn-primary edit" data-id="@property.ResidentialPropertyId">Edit</button>
                        @Ajax.ActionLink("Delete", "DeleteProperty", "Landlords",
                        new { id = property.ResidentialPropertyId },
                        new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", UpdateTargetId = "landlord-properties", OnBegin = "return confirm('Are you sure you want to delete this property?');" },
                        new { @class = "btn btn-primary" })
                        @if (property.PropertyPhotos.Count == 0)
                        {
                            <button class="btn btn-primary upload" data-id="@property.ResidentialPropertyId">No photos - add now!</button>
                        }
                        else
                        {
                            <button class="btn btn-primary upload" data-id="@property.ResidentialPropertyId">Add more photos</button>
                        }
                    </div>
                </div>
            </div>
        </div>
        }
    }
</div>
<div class="modal hide fade in" id="create-residential-property-modal" data-url="@Url.Action("LandlordProperties", "Landlords")">
    <div id="create-property-container"></div>
</div>
<div class="modal hide fade in" id="view-property">
    <div id="view-property-container"></div>
</div>
<div class="modal hide fade in" id="edit-property">
    <div id="edit-property-container"></div>
</div>
<div class="modal hide fade in" id="upload-photo">
    <div id="upload-photo-container"></div>
</div>
